package com.zk.cq.constant;/**
 * Created by 15911 on 2019/6/30.
 */

import com.zk.cq.model.req.admin.AdminChangeEvent;
import com.zk.cq.model.req.friend.AddFriendEvent;
import com.zk.cq.model.req.friend.FriendValidEvent;
import com.zk.cq.model.req.group.AddGroupValidEvent;
import com.zk.cq.model.req.member.MemberChangeEvent;
import com.zk.cq.model.req.message.DiscussMsgEvent;
import com.zk.cq.model.req.message.GroupMsgEvent;
import com.zk.cq.model.req.message.PrivateMsgEvent;
import com.zk.cq.model.req.meta.HeartbeatEventReq;
import com.zk.cq.model.req.meta.LifeEventReq;
import com.zk.cq.model.req.upload.UploadFileEventReq;

/**
 * @ClassName TypeToParam
 * @Descripyion 根据类型获取参数类型
 * @Author zhangkuan
 * @Date 2019/6/30 10:22
 **/
public enum TypeToParam {
    MESSAGE_PRIVATE(PostTypes.MESSAGE, PostTypes.MessageType.PRIVATE, PrivateMsgEvent.class),
    MESSAGE_GROUP(PostTypes.MESSAGE, PostTypes.MessageType.GROUP, GroupMsgEvent.class),
    MESSAGE_DISCUSS(PostTypes.MESSAGE, PostTypes.MessageType.DISCUSS, DiscussMsgEvent.class),

    NOTICE_GROUP_UPLOAD(PostTypes.NOTICE, PostTypes.NoticeType.GROUP_UPLOAD, UploadFileEventReq.class),
    NOTICE_GROUP_ADMIN(PostTypes.NOTICE, PostTypes.NoticeType.GROUP_ADMIN, AdminChangeEvent.class),
    NOTICE_GROUP_DECREASE(PostTypes.NOTICE, PostTypes.NoticeType.GROUP_DECREASE, MemberChangeEvent.class),
    NOTICE_GROUP_INCREASE(PostTypes.NOTICE, PostTypes.NoticeType.GROUP_INCREASE, MemberChangeEvent.class),
    NOTICE_FRIEND_ADD(PostTypes.NOTICE, PostTypes.NoticeType.FRIEND_ADD, AddFriendEvent.class),

    REQUEST_FRIEND(PostTypes.REQUEST, PostTypes.RequestType.FRIEND, FriendValidEvent.class),
    REQUEST_GROUP(PostTypes.REQUEST, PostTypes.RequestType.GROUP, AddGroupValidEvent.class),

    META_EVENT_LIFECYCLE(PostTypes.META_EVENT, PostTypes.MetaEventType.LIFECYCLE, LifeEventReq.class),
    META_EVENT_HEARTBEAT(PostTypes.META_EVENT, PostTypes.MetaEventType.HEARTBEAT, HeartbeatEventReq.class),

    ;
    private String postType;
    private String eventType;
    private Class clazz;

    TypeToParam(String postType, String eventType, Class clazz) {
        this.postType = postType;
        this.eventType = eventType;
        this.clazz = clazz;
    }

    public static Class getParamClass(String posttype, String eventType) {
        if (PostTypes.MESSAGE.equals(posttype) && PostTypes.MessageType.PRIVATE.equals(eventType)) {
            return MESSAGE_PRIVATE.getClazz();
        } else if (PostTypes.MESSAGE.equals(posttype) && PostTypes.MessageType.GROUP.equals(eventType)) {
            return MESSAGE_GROUP.getClazz();
        } else if (PostTypes.MESSAGE.equals(posttype) && PostTypes.MessageType.DISCUSS.equals(eventType)) {
            return MESSAGE_DISCUSS.getClazz();
        } else if (PostTypes.NOTICE.equals(posttype) && PostTypes.NoticeType.GROUP_UPLOAD.equals(eventType)) {
            return NOTICE_GROUP_UPLOAD.getClazz();
        } else if (PostTypes.NOTICE.equals(posttype) && PostTypes.NoticeType.GROUP_ADMIN.equals(eventType)) {
            return NOTICE_GROUP_ADMIN.getClazz();
        } else if (PostTypes.NOTICE.equals(posttype) && PostTypes.NoticeType.GROUP_DECREASE.equals(eventType)) {
            return NOTICE_GROUP_DECREASE.getClazz();
        } else if (PostTypes.NOTICE.equals(posttype) && PostTypes.NoticeType.GROUP_INCREASE.equals(eventType)) {
            return NOTICE_GROUP_INCREASE.getClazz();
        } else if (PostTypes.NOTICE.equals(posttype) && PostTypes.NoticeType.FRIEND_ADD.equals(eventType)) {
            return NOTICE_FRIEND_ADD.getClazz();
        } else if (PostTypes.REQUEST.equals(posttype) && PostTypes.RequestType.FRIEND.equals(eventType)) {
            return REQUEST_FRIEND.getClazz();
        } else if (PostTypes.REQUEST.equals(posttype) && PostTypes.RequestType.GROUP.equals(eventType)) {
            return REQUEST_GROUP.getClazz();
        } else if (PostTypes.META_EVENT.equals(posttype) && PostTypes.MetaEventType.LIFECYCLE.equals(eventType)) {
            return META_EVENT_LIFECYCLE.getClazz();
        } else if (PostTypes.META_EVENT.equals(posttype) && PostTypes.MetaEventType.HEARTBEAT.equals(eventType)) {
            return META_EVENT_HEARTBEAT.getClazz();
        }
        return null;
    }

    public String getPostType() {
        return postType;
    }

    public void setPostType(String postType) {
        this.postType = postType;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public Class getClazz() {
        return clazz;
    }

    public void setClazz(Class clazz) {
        this.clazz = clazz;
    }
}
